#pragma once
#include <iostream>
#include <string>
#include <map>

namespace protocol_ns
{

    // class CalResponse
    class Response
    {
    public:
        enum HttpStatusCode
        {
            Unknown,
            OK = 200,
            BADREQUEST = 400,
            NOTFOUND = 404
        };

        Response() {}

        // struct->string
        bool Serialize(std::string *outStr)
        {
            for (auto &kv : headers_)
            {

                *outStr += kv.first;
                *outStr += ":";
                *outStr += kv.second;
                *outStr += "\n";
            }

            *outStr += '\n';

            // 写入body
            *outStr += body_ + '\n';
        }

        // string->struct
        bool Deserialize(const std::string &inStr)
        {
        }

        ~Response() {}

        void setBody(const std::string &body)
        {
            body_ = body;
        }

        void setContentType(const std::string &contentType)
        {
            addHeader("Content-Type", contentType);
        }

        void addHeader(const std::string key, const std::string val)
        {
            headers_[key] = val;
        }

    private:
        std::string body_;
        std::map<std::string, std::string> headers_;
    };
}
